package com.tencent.wxcloudrun.service.impl;

import com.tencent.wxcloudrun.dto.GoodsAddition;
import com.tencent.wxcloudrun.dto.Shippingcar;
import com.tencent.wxcloudrun.dto.Shippingcaradditions;
import com.tencent.wxcloudrun.mapper.ShippingcaradditionsMapper;
import com.tencent.wxcloudrun.service.ShippingcaradditionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lichongbing
 * @version 1.0.0
 * @createdate 2023/3/15 21:35
 * @description: TODO
 */
@Service
public class ShippingcaradditionsServiceImpl implements ShippingcaradditionsService {
    @Autowired
    private ShippingcaradditionsMapper shippingcaradditionsMapper;

    @Override
    public int addShippingCarAdditions(List<GoodsAddition> goodsAddition, String shippingcarid) {
        int k = 0;
        for (int i = 0; i < goodsAddition.size(); i++) {
            shippingcaradditionsMapper.addShippingCarAdditions(goodsAddition.get(i).getId(), goodsAddition.get(i).getPid(), shippingcarid);
           k=i;
        }
        return k;
    }

    @Override
    public List<Shippingcar> getShippingcar(String openid) {
        List<Shippingcar> shippingcar = shippingcaradditionsMapper.getShippingcar(openid);
        return shippingcar;
    }

    @Override
    public List<Shippingcaradditions> getShippingcaradditions(Integer id) {

        return shippingcaradditionsMapper.getContradistinctions(id);
    }
}
